FROM {{ namespace }}/{{ image_prefix }}keystone-base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block keystone_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{% if base_package_type == 'rpm' %}
    {% set keystone_packages = [
        'mod_auth_gssapi',
    ] %}
{% elif base_package_type == 'deb' %}
    {% set keystone_packages = [
        'libapache2-mod-auth-gssapi',
    ] %}
{% endif %}
{{ macros.install_packages(keystone_packages | customizable("packages")) }}
ADD plugins-archive /

{% set keystone_plugins_pip_packages = [
    '/plugins/*',
    'requests-kerberos',
] %}

COPY keystone_bootstrap.sh /usr/local/bin/kolla_keystone_bootstrap
COPY extend_start.sh /usr/local/bin/kolla_extend_start

RUN chmod 644 /usr/local/bin/kolla_extend_start \
    && chmod 755 /usr/local/bin/kolla_keystone_bootstrap \
    && if [ "$(ls /plugins)" ]; then \
        {{ macros.install_pip(keystone_plugins_pip_packages) }}; \
    fi

{% block keystone_footer %}{% endblock %}
{% block footer %}{% endblock %}
